import socket
import sys

def ed(data):
	return bytes(str(data), 'UTF-8')

def dd(data):
	return eval(data.decode('UTF-8'))

serverAddr = sys.argv[1]

port = 6665

print("Binding socket")
sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
sock.bind( ("", port) )

print("Sending 'hello'")
sock.sendto( ed(str({"type":"hello"})), (serverAddr, port+1) )

print("Listening for response")
(data, addr) = sock.recvfrom(2048)
print(dd(data))